import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
    {
        path: '/login',
        component: () => import('@/views/login/index'),
        hidden: true
    },
    {
        path: '/auth-redirect',
        component: () => import('@/views/login/auth-redirect'),
        hidden: true
    },
    {
        path: '/404',
        component: () => import('@/views/error-page/404'),
        hidden: true
    },
    {
        path: '/401',
        component: () => import('@/views/error-page/401'),
        hidden: true
    },
    {
        path: '/',
        component: Layout,
        redirect: '/goods/list',
        noShow: true,
        // children: [
        //     {
        //         path: 'dashboard',
        //         component: () => import('@/views/dashboard/index'),
        //         name: 'Dashboard',
        //         meta: { title: '首页', icon: 'dashboard', affix: true,noShow: true, }
        //     }
        // ]
    },
    {
        path: '/member',
        component: Layout,
        redirect: '/member/list',
        alwaysShow: true,
        name: 'Member',
        meta: {
            title: '会员管理',
            icon: 'member'
        },
        children: [
            {
                path: 'list',
                component: () => import('@/views/member/index.vue'),
                name: 'memberList',
                meta: { title: '注册会员管理', noCache: true,keepAliveFlag: true}
            },
            {
                path: 'detail',
                component: () => import('@/views/member/detail.vue'),
                name: 'MemberDetail',
                meta: { title: '会员详情', noCache: true,noShow:true }
            },
        ]
    },
    {
        path: '/shops',
        component: Layout,
        redirect: '/shops/list',
        alwaysShow: true,
        name: 'Shops',
        meta: {
            title: '商铺管理',
            icon: 'shop'
        },
        children: [
            {
                path: 'list',
                component: () => import('@/views/shops/index.vue'),
                name: 'ShopsList',
                meta: { title: '商铺管理', noCache: true,keepAliveFlag: true }
            },
            {
                path: 'add',
                component: () => import('@/views/shops/add.vue'),
                name: 'ShopsAdd',
                meta: { title: '创建商铺', noCache: true,noShow:true }
            },
            {
                path: 'look/:id',
                component: () => import('@/views/shops/look.vue'),
                name: 'ShopsLook',
                meta: { title: '商铺详情', noCache: true,noShow:true }
            },
        ]
    },
    {
        path: '/goods',
        component: Layout,
        redirect: '/goods/list',
        alwaysShow: true,
        name: 'Goods',
        meta: {
            title: '商品管理',
            icon: 'goods'
        },
        children: [
            {
                path: 'category',
                component: () => import('@/views/goods/category'),
                name: 'GoodsCategory',
                meta: {
                    title: '商品分类管理',
                    noCache: true,
                    keepAliveFlag: true
                }
            },
            {
                path: 'list',
                component: () => import('@/views/goods/index'),
                name: 'GoodsList',
                meta: {
                    title: '商品管理',
                    keepAliveFlag: true,
                }
            },
            {
                path: 'add',
                component: () => import('@/views/goods/add'),
                name: 'GoodsAdd',
                meta: {
                    title: '商品发布',
                },
                hidden: true
            },
            {
                path: 'look/:id',
                component: () => import('@/views/goods/look'),
                name: 'GoodsDetail',
                meta: {
                    title: '商品详情',
                },
                hidden: true
            },
            {
                path: 'order',
                component: () => import('@/views/goods/order'),
                name: 'GoodsOrder',
                meta: {
                    title: '订单合约管理',
                    keepAliveFlag: true
                }
            },
            {
                path: 'order/:id',
                component: () => import('@/views/goods/order/detail'),
                name: 'OrderDetail',
                meta: {
                    title: '订单详情',
                    //keepAliveFlag: true,
                },
                hidden: true
            }
        ]
    },
    {
        path: '/advertising',
        component: Layout,
        redirect: '/advertising/release',
        alwaysShow: true,
        name: 'Advertising',
        meta: {
            title: '广告投放管理',
            icon: 'ad'
        },
        children: [
            {
                path: 'release',
                component: () => import('@/views/advertising/release'),
                name: 'AdvertisingRelease',
                meta: {
                    title: '广告投放管理',
                    keepAliveFlag: true,
                }
            },
            {
                path: 'release/:id',
                component: () => import('@/views/advertising/release/detail'),
                name: 'AdvertisingDetail',
                meta: {
                    title: '广告投放详情',
                },
                hidden: true
            },
            {
                path: 'complaint',
                component: () => import('@/views/advertising/complaint'),
                name: 'AdvertisingComplaint',
                meta: {
                    title: '广告投诉管理',
                    keepAliveFlag: true
                }
            },
            {
                path: 'complaint/:id',
                component: () => import('@/views/advertising/complaint/detail'),
                name: 'ComplaintDetail',
                meta: {
                    title: '广告投诉详情'
                },
                hidden: true
            },
        ]
    },
    {
        path: '/content',
        component: Layout,
        redirect: '/content/list',
        alwaysShow: true,
        name: 'Content',
        meta: {
            title: '内容管理',
            icon: 'content'
        },
        children: [
            {
                path: 'list',
                component: () => import('@/views/content/index.vue'),
                name: 'ContentList',
                meta: { title: '内容管理', noCache: true,keepAliveFlag: true }
            },
            {
                path: 'add',
                component: () => import('@/views/content/add.vue'),
                name: 'ContentAdd',
                meta: { title: '创建内容', noCache: true,noShow:true }
            },
        ]
    },
    {
        path: '/industry',
        component: Layout,
        alwaysShow: true,
        name: 'Industry',
        meta: {
            title: '产业管理',
            icon: 'chanye'
        },
        children: [
            {
                path: 'area',
                component: () => import('@/views/industry/area/index'),
                name: 'Area',
                meta: {
                    title: '区域管理',
                    keepAliveFlag: true,
                }
            },
            {
                path: 'arlandmark',
                component: () => import('@/views/industry/arLandmark/index'),
                name: 'Arlandmark',
                meta: {
                    title: 'AR地标管理',
                    keepAliveFlag: true,
                }
            },
            {
                path: 'arlandmark/add',
                component: () => import('@/views/industry/arLandmark/add.vue'),
                name: 'ArlandmarkAdd',
                meta: { title: '创建AR地标', noCache: true},
                hidden: true
            },
            {
                path: 'arlandmark/look/:id',
                component: () => import('@/views/industry/arLandmark/look.vue'),
                name: 'ArlandmarkLook',
                meta: { title: 'AR地标详情', noCache: true},
                hidden: true
            },
            {
                path: 'advert',
                component: () => import('@/views/industry/advert/index'),
                name: 'Advert',
                meta: {
                    title: 'AR广告位管理',
                    keepAliveFlag: true,
                }
            },
            {
                path: 'advert/add',
                component: () => import('@/views/industry/advert/add.vue'),
                name: 'AdvertAdd',
                meta: { title: '创建AR广告位', noCache: true},
                hidden: true
            },
            {
                path: 'advert/look/:id',
                component: () => import('@/views/industry/advert/look.vue'),
                name: 'AdvertLook',
                meta: { title: 'AR广告位详情', noCache: true},
                hidden: true
            },
            {
                path: 'prop',
                component: () => import('@/views/industry/prop/index'),
                name: 'Prop',
                meta: {
                    title: '道具管理',
                    keepAliveFlag: true,
                }
            },
            {
                path: 'prop/add',
                component: () => import('@/views/industry/prop/add.vue'),
                name: 'PropAdd',
                meta: { title: '创建道具', noCache: true},
                hidden: true
            },
            {
                path: 'prop/look/:id',
                component: () => import('@/views/industry/prop/look.vue'),
                name: 'PropLook',
                meta: { title: '道具详情', noCache: true},
                hidden: true
            },
        ]
    },
    // {
    //     path: '/finance',
    //     component: Layout,
    //     redirect: '/finance/chain',
    //     alwaysShow: true,
    //     name: 'Finance',
    //     meta: {
    //         title: '财务管理',
    //         icon: 'goods'
    //     },
    //     children: [
    //         {
    //             path: 'chain',
    //             component: () => import('@/views/finance/chain'),
    //             name: 'FinanceChain',
    //             meta: {
    //                 title: '链上钱包地址管理',
    //                 keepAliveFlag: true,
    //             }
    //         },
    //         {
    //             path: 'privateChain',
    //             component: () => import('@/views/finance/privateChain'),
    //             name: 'FinancePrivateChain',
    //             meta: {
    //                 title: '私链钱包地址管理',
    //                 keepAliveFlag: true
    //             }
    //         },
    //         {
    //             path: 'detail/:id',
    //             component: () => import('@/views/finance/detail'),
    //             name: 'FinanceDetail',
    //             meta: {
    //                 title: '钱包详情'
    //             },
    //             hidden: true
    //         },
    //     ]
    // },
    {
        path: '/activity',
        component: Layout,
        redirect: '/activity/list',
        alwaysShow: true,
        name: 'Activity',
        meta: {
            title: '活动管理',
            icon: 'huodong'
        },
        children: [
            {
                path: 'list',
                component: () => import('@/views/activity/index.vue'),
                name: 'ActivityList',
                meta: { title: '活动管理', noCache: true,keepAliveFlag: true }
            },
            {
                path: 'add',
                component: () => import('@/views/activity/add.vue'),
                name: 'ActivityAdd',
                meta: { title: '添加活动', noCache: true,noShow:true }
            },
            {
                path: 'look/:id',
                component: () => import('@/views/activity/look.vue'),
                name: 'ActivityLook',
                meta: { title: '活动详情', noCache: true,noShow:true }
            },
        ]
    },
    {
        path: '/card',
        component: Layout,
        redirect: '/card/list',
        alwaysShow: true,
        name: 'Card',
        meta: {
            title: '卡片管理',
            icon: 'card'
        },
        children: [
            {
                path: 'list',
                component: () => import('@/views/card/index.vue'),
                name: 'CardList',
                meta: { title: '原创卡片管理', noCache: true,keepAliveFlag: true }
            },
            {
                path: 'add',
                component: () => import('@/views/card/add.vue'),
                name: 'CardAdd',
                meta: { title: '添加卡片', noCache: true,noShow:true }
            },
            {
                path: 'look/:id',
                component: () => import('@/views/card/look.vue'),
                name: 'CardLook',
                meta: { title: '卡片详情', noCache: true,noShow:true }
            },
        ]
    },
    {
        path: '/forget',
        component: Layout,
        redirect: '/forget/list',
        alwaysShow: true,
        name: 'Forget',
        meta: {
            title: 'NFT锻造管理',
            icon: 'duanzao'
        },
        children: [
            {
                path: 'list',
                component: () => import('@/views/forget/index.vue'),
                name: 'ForgetList',
                meta: { title: 'NFT锻造管理', noCache: true,keepAliveFlag: true }
            },
            {
                path: 'add',
                component: () => import('@/views/forget/add.vue'),
                name: 'ForgetAdd',
                meta: { title: '锻造', noCache: true,noShow:true }
            },
            {
                path: 'look/:id',
                component: () => import('@/views/forget/look.vue'),
                name: 'ForgetLook',
                meta: { title: '锻造详情', noCache: true,noShow:true }
            },
        ]
    },
    {
        path: '/trade',
        component: Layout,
        redirect: '/trade/list',
        alwaysShow: true,
        name: 'Trade',
        meta: {
            title: 'NFT交易管理',
            icon: 'trade'
        },
        children: [
            {
                path: 'list',
                component: () => import('@/views/trade/auction'),
                name: 'NftAuction',
                meta: {
                    title: 'NFT拍卖交易',
                    keepAliveFlag: true,
                }
            },
            {
                path: 'detail/:type/:id',
                component: () => import('@/views/trade/detail'),
                name: 'NftTradeDetail',
                meta: {
                    title: 'NFT交易详情',
                },
                hidden: true
            },
            {
                path: 'sell',
                component: () => import('@/views/trade/sell'),
                name: 'NftSell',
                meta: {
                    title: 'NFT寄售交易',
                    keepAliveFlag: true
                }
            }
        ]
    },
    {
        path: '/dao',
        component: Layout,
        redirect: '/dao/list',
        alwaysShow: true,
        name: 'DAO',
        meta: {
            title: 'DAO管理',
            icon: 'dao'
        },
        children: [
            {
                path: 'list',
                component: () => import('@/views/dao/index.vue'),
                name: 'DaoList',
                meta: { title: 'DAO管理', noCache: true,keepAliveFlag: true}
            },
            {
                path: 'detail',
                component: () => import('@/views/dao/detail.vue'),
                name: 'DaoDetail',
                meta: { title: '会DAO详情', noCache: true,noShow:true }
            },
        ]
    }
]


/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
    { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router
